<?php


namespace App\Model;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;


class LogSummary  extends Model {
    protected $table = 'log_summary';
    protected $primaryKey = 'id';
    protected $dates = [
        'created_at',
        'updated_at',
    ];

    public static function add($key="",$value=""){
        $first =DB::table("log_summary")->where("date",date("Y-m-d"))->first();
        if(empty($first)){
            $insert['login_num'] =1;
            $insert['register_num'] =1;
            $insert['date'] =date('Y-m-d');
            $insert['create_at'] =date("Y-m-d H:i:s",time());
            $insert['update_at'] =date("Y-m-d H:i:s",time());
            return DB::table("log_summary")->insertGetId($insert);
        }else{
             DB::table("log_summary")->increment("login_num",1);
             DB::table("log_summary")->increment("register_num",1);
             return true;
        }

    }
}
